﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

using Bird.OAWeb.Service.IService;
using Bird.OAWeb.Domain.DTO;
using Bird.OAWeb.Domain.Table;
using Bird.OAWeb.Service;
using Bird.OAWeb.WebAPI.Filters;
using Microsoft.AspNetCore.Authorization;

namespace Bird.OAWeb.WebAPI.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    [Authorize]
    public class RoleController : ControllerBase
    {
        IRoleService roleService;

        public RoleController(IRoleService roleService)
        {
            this.roleService = roleService;
        }
        /// <summary>
        /// 角色添加
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        [ResponseHeader("xxx", "yyy")]
        public IActionResult  RoleAdd(Role model)
        {
            return Ok(roleService.RoleAdd(model));
        }
        /// <summary>
        /// 角色显示
        /// </summary>
        /// <param name="pageList"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        [HttpGet]
        public IActionResult RoleShow(int pageIndex = 1, int pageSize = 2)
        {
            return Ok(roleService.RoleShow(pageIndex,pageSize));
        }
        /// <summary>
        /// 角色删除
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpDelete]
        public IActionResult RoleDelete(int id)
        {
            return Ok(roleService.RoleDelete(id));
        }
        /// <summary>
        /// 角色反填
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet]
        public IActionResult RoleBind(int id)
        {
            return Ok(roleService.RoleBind(id));
        }
        /// <summary>
        /// 角色修改
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPut]
        public IActionResult  RoleUpdate(Role model)
        {
            return Ok(roleService.RoleUpdate(model));
        }
    }
}
